#include<iostream>
#include<cmath>
#include<set>
#include<vector>
#include<algorithm>
#include<unordered_map>
using namespace std;
typedef long long LL;
int n;
int mp[5100100];
int main()
{
	int t;
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		if(n==0){
			printf("0\n");
			continue;
		}
		LL cnt=0;
		int z=sqrt(n);
		for(int i=1;i<=510000;i++){
			mp[i]=0;
		}
        for(int i=0;i<=z;i++){
        	for(int j=0;j<=z;j++){
        		if(i*i+j*j>n)break;
        		for(int k=0;k<=z;k++){
        			if(i*i+j*j+k*k>n)break;
        			int temp=n-i*i-j*j-k*k; 
					int zz=sqrt(temp);
					if(zz*zz==temp){
//						cout<<i*i+j*j+k*k+temp<<endl;
                        vector<int>ans;
                        ans.push_back(i);
                        ans.push_back(j);
                        ans.push_back(k);
                        ans.push_back(zz);
                        sort(ans.begin(),ans.end()); 
                        LL ans1=ans[3]*123+ans[2]*11+ans[1]*1+ans[0];
                        for(int x:ans){
                        	cout<<"x=="<<x<<endl;
						}
						cout<<"------------"<<endl;
                        //cout<<"ans1=="<<ans1<<endl;
						//cout<<"ans1==="<<ans1<<endl;
                        //cout<<"ans1=="<<ans1<<endl;
                        if(mp[ans1]==1)continue;
                        else{
                        	mp[ans1]=1;
						    cnt++;
						}
					} 
				}
			}
		}
		printf("%lld\n",cnt);
	}
	return 0;
} 
